<template>
  <view class="container">
    <Pages :items="items" />
  </view>
</template>

<script>
import { detail } from '@/api/page'
import Pages from '@/components/page/index.vue'
export default {
  components: {
    Pages
  },
  data () {
    return {
      items: []
    }
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad (options) {
    this.HomePageData()
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow () {},

  methods: {
    // 获取页面数据
    async HomePageData () {
      const res = await detail(0)
      // console.log(res)
      this.items = res.data.pageData.items
      this.HomePageStyle(res.data.pageData.page)
    },
    // 设置头部导航栏样式
    HomePageStyle (page) {
      console.log(page)
      uni.setNavigationBarTitle({ title: page.params.name })
      uni.setNavigationBarColor({
        frontColor:
          page.style.titleTextColor === 'white' ? '#ffffff' : '#000000',
        backgroundColor: page.style.titleBackgroundColor
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.container {
  background: #fff;
}

.diy-search {
  background: #f1f1f2;
  padding: 20rpx 20rpx;
  font-size: 26rpx;
}

.inner {
  height: 60rpx;
  background: #fff;
  overflow: hidden;

  &.radius {
    border-radius: 10rpx;
  }

  &.round {
    border-radius: 60rpx;
  }
}

.search-input {
  height: 60rpx;
  line-height: 60rpx;
  color: #999;
  padding: 0 20rpx;

  .search-icon {
    margin-right: 8rpx;
  }
}

.diy-banner {
  position: relative;

  // swiper组件
  .swiper-box {
    height: 100%;

    .slide-image {
      width: 100%;
      height: 100%;
      margin: 0 auto;
      display: block;
    }
  }

  /* 指示点 */
  .indicator-dots {
    width: 100%;
    height: 28rpx;
    padding: 0 20rpx;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 20rpx;
    opacity: 0.8;
    display: flex;
    justify-content: center;

    .dots-item {
      width: 16rpx;
      height: 16rpx;
      margin-right: 8rpx;
      background-color: #fff;

      &:last-child {
        margin-right: 0;
      }

      &.active {
        background-color: #313131 !important;
      }
    }

    // 圆形
    &.round .dots-item {
      width: 16rpx;
      height: 16rpx;
      border-radius: 20rpx;
    }

    // 正方形
    &.square .dots-item {
      width: 16rpx;
      height: 16rpx;
    }

    // 长方形
    &.rectangle .dots-item {
      width: 22rpx;
      height: 14rpx;
    }
  }
}

.diy-navBar .data-list::after {
  clear: both;
  content: ' ';
  display: table;
}

.item-nav {
  float: left;
  margin: 10px 0;
  text-align: center;

  .item-text {
    font-size: 26rpx;
  }

  .item-image {
    margin-bottom: 4px;
    font-size: 0;
  }

  .item-image .image {
    width: 88rpx;
    height: 88rpx;
  }
}

/* 分列布局 */

.diy-navBar .avg-sm-3 > .item-nav {
  width: 33.33333333%;
}

.diy-navBar .avg-sm-4 > .item-nav {
  width: 25%;
}

.diy-navBar .avg-sm-5 > .item-nav {
  width: 20%;
}

.diy-goods {
  .goods-list {
    padding: 4rpx;
    box-sizing: border-box;

    .goods-item {
      box-sizing: border-box;
      padding: 6rpx;

      .goods-image {
        position: relative;
        width: 100%;
        height: 0;
        padding-bottom: 100%;
        overflow: hidden;
        background: #fff;

        &:after {
          content: '';
          display: block;
          margin-top: 100%;
        }

        .image {
          position: absolute;
          width: 100%;
          height: 100%;
          top: 0;
          left: 0;
          -o-object-fit: cover;
          object-fit: cover;
        }
      }

      .detail {
        padding: 8rpx;
        background: #fff;

        .goods-name {
          min-height: 68rpx;
          line-height: 1.3;
          white-space: normal;
          color: #484848;
          font-size: 26rpx;
        }

        .detail-price {
          .goods-price {
            margin-right: 8rpx;
          }

          .line-price {
            text-decoration: line-through;
          }
        }
      }
    }

    &.display__slide {
      white-space: nowrap;
      font-size: 0;

      .goods-item {
        display: inline-block;
      }
    }

    &.display__list {
      .goods-item {
        float: left;
      }
    }

    &.column__2 {
      .goods-item {
        width: 50%;
      }
    }

    &.column__3 {
      .goods-item {
        width: 33.33333%;
      }
    }

    &.column__1 {
      .goods-item {
        width: 100%;
        height: 280rpx;
        margin-bottom: 12rpx;
        padding: 20rpx;
        box-sizing: border-box;
        background: #fff;
        line-height: 1.6;

        &:last-child {
          margin-bottom: 0;
        }
      }

      .goods-item_left {
        display: flex;
        width: 40%;
        background: #fff;
        align-items: center;

        .image {
          display: block;
          width: 240rpx;
          height: 240rpx;
        }
      }

      .goods-item_right {
        position: relative;
        width: 60%;

        .goods-name {
          margin-top: 20rpx;
          min-height: 68rpx;
          line-height: 1.3;
          white-space: normal;
          color: #484848;
          font-size: 26rpx;
        }
      }

      .goods-item_desc {
        margin-top: 8rpx;
      }

      .desc-selling_point {
        width: 400rpx;
        font-size: 24rpx;
        color: #e49a3d;
      }

      .desc-goods_sales {
        color: #999;
        font-size: 24rpx;
      }

      .desc_footer {
        font-size: 24rpx;

        .price_x {
          margin-right: 16rpx;
          color: #f03c3c;
          font-size: 30rpx;
        }

        .price_y {
          text-decoration: line-through;
        }
      }
    }
  }
}

.diy-video .video {
  width: 100%;
  display: block;
}

.diy-article {
  background: #f7f7f7;

  .article-item {
    margin-bottom: 20rpx;
    padding: 30rpx;
    background: #fff;

    &:last-child {
      margin-bottom: 0;
    }

    .article-item__title {
      max-height: 74rpx;
      font-size: 28rpx;
      line-height: 38rpx;
      color: #333;
    }

    .article-item__image .image {
      display: block;
    }
  }
}

/* 小图模式 */

.show-type__10 {
  display: flex;

  .article-item__left {
    padding-right: 20rpx;
  }

  .article-item__title {
    // min-height: 72rpx;
  }

  .article-item__image .image {
    width: 240rpx;
  }
}

/* 大图模式 */

.show-type__20 .article-item__image .image {
  width: 100%;
}

.diy-article {
  background: #f7f7f7;

  .article-item {
    margin-bottom: 20rpx;
    padding: 30rpx;
    background: #fff;

    &:last-child {
      margin-bottom: 0;
    }

    .article-item__title {
      max-height: 74rpx;
      font-size: 28rpx;
      line-height: 38rpx;
      color: #333;
    }

    .article-item__image .image {
      display: block;
    }
  }
}

/* 小图模式 */

.show-type__10 {
  display: flex;

  .article-item__left {
    padding-right: 20rpx;
  }

  .article-item__title {
    // min-height: 72rpx;
  }

  .article-item__image .image {
    width: 240rpx;
  }
}

/* 大图模式 */

.show-type__20 .article-item__image .image {
  width: 100%;
}
.diy-service {
  position: fixed;
  z-index: 999;
  right: calc(var(--window-right) + var(--right));
  bottom: calc(
    constant(safe-area-inset-bottom) + var(--window-bottom) + var(--bottom)
  );
  bottom: calc(
    env(safe-area-inset-bottom) + var(--window-bottom) + var(--bottom)
  );

  .service-icon {
    padding: 10rpx;

    .image {
      display: block;
      width: 90rpx;
      height: 90rpx;
      border-radius: 50%;
      box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1);
    }
  }
}
</style>
